package com.fhz.circle.food;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;

import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.fhz.circle.R;
import com.fhz.circle.common.RetrofitFactory;
import com.fhz.circle.common.RetrofitFactory2;
import com.fhz.circle.databinding.ActivityFoodBinding;
import com.fhz.circle.databinding.ActivityRegisterBinding;
import com.fhz.circle.register.view.RegisterViewModel;
import com.fhz.core_lib.mvvm.BaseMVVMActivity;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * @author: fhz
 * @describe:
 * @date: 2021-11-14 19:08:56
 */

public class FoodActivity extends BaseMVVMActivity<UserCenterViewModel, ActivityFoodBinding> {


    private static final String TAG = "FoodActivity";
    @Override
    protected UserCenterViewModel createViewModel() {
        return ViewModelProviders.of(this,new UserCenterViewModelFactory()).get(UserCenterViewModel.class);
    }



    @Override
    protected int getLayoutId() {
        return R.layout.activity_food;
    }

    @Override
    protected void initView() {

//        Toast.makeText(this, "aaa", Toast.LENGTH_SHORT).show();
//

//        viewModel.getFood().observe(this, new Observer<Food>() {
//            @Override
//            public void onChanged(Food food) {
//                Toast.makeText(FoodActivity.this, "dd"+food.getData().size(), Toast.LENGTH_SHORT).show();
//            }
//        });

        viewModel.getFood().observe(this, new Observer<Food>() {
            @Override
            public void onChanged(Food food) {
                binding.setFood(food);
                Toast.makeText(FoodActivity.this, "aa"+food.getData().size(), Toast.LENGTH_SHORT).show();
            }
        });
        
    }

    @Override
    protected void initData() {

    }
}
